package cn.eonshine.cuba.inf.modular.biz.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import cn.eonshine.cuba.inf.common.http.InfStatus;
import cn.eonshine.cuba.inf.modular.biz.entity.IndustryRealData;
import cn.eonshine.cuba.inf.modular.biz.mapper.IndustryRealDataMapper;
import cn.eonshine.cuba.inf.modular.biz.service.IIndustryRealDataService;
import cn.eonshine.cuba.inf.modular.common.service.AbstractCommonService;

@Service
@Transactional
public class IndustryRealDataServiceImpl extends AbstractCommonService<IndustryRealDataMapper, IndustryRealData> implements IIndustryRealDataService {

	
	@Override
	public QueryWrapper<IndustryRealData> customerQueryWrapper() {
		QueryWrapper<IndustryRealData> entity = new QueryWrapper<IndustryRealData>();
		entity.eq("a.lsms_update", InfStatus.LSMS_UPDATE_EXTRACT_NO);
		entity.orderByAsc("a.CREATE_DATE ASC,a.lsms_update");
		return entity;
	}

	@Override
	public int transportDataHandle(IndustryRealData obj, int count) throws Exception {
		
		QueryWrapper<IndustryRealData> entity = new QueryWrapper<IndustryRealData>();
//		entity.lambda().eq(IndustryRealData::getDataInputDatetime, obj.getDataInputDatetime());
//		entity.lambda().eq(IndustryRealData::getIndustryId, obj.getIndustryId());
//		entity.lambda().eq(IndustryRealData::getDepotId, obj.getDepotId());
//		entity.lambda().eq(IndustryRealData::getRptDate, obj.getRptDate());
		entity.lambda().eq(IndustryRealData::getOilId, obj.getOilId());
		entity.lambda().eq(IndustryRealData::getBillId, obj.getBillId());
		
		boolean isSuccess = false;
		if(this.isUpdate==0){
			isSuccess = remove(entity);
		}else {
			isSuccess = update(obj, entity);
		}
		if(isSuccess) {
			count ++;
		}
		return count;
	}

	@Override
	public void mappingHandle(IndustryRealData obj) throws Exception {
		
	}

	@Override
	public boolean isUseCutomerSelectSQL() {
		return true;
	}

}
